package com.atguigu.yygh.hosp.controller.admin;

import com.atguigu.yygh.common.result.R;
import com.atguigu.yygh.hosp.service.HospitalService;
import com.atguigu.yygh.model.hosp.Hospital;
import com.atguigu.yygh.vo.hosp.HospitalQueryVo;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;


/**
 * @Author luoyin
 * @Date 21:28 2022/9/27
 **/
@RestController
@RequestMapping("/admin/hosp/hospital")
@Api(description = "医院管理")
public class HospitalController {

    @Autowired
    private HospitalService hospitalService;

    @PostMapping("/{pageNum}/{pageSize}")
    public R page(@PathVariable Integer pageNum, @PathVariable Integer pageSize , @RequestBody HospitalQueryVo hospitalQueryVo){
        Page<Hospital> pages = hospitalService.selectPage(pageNum,pageSize,hospitalQueryVo);
        return R.ok().data("pages",pages);
    }
    
    @GetMapping("/getHospById/{id}")
    public R getHospById(@PathVariable String id){
        Hospital hospital = hospitalService.getHospById(id);
        return R.ok().data("hospital",hospital);
    }

    @PutMapping("/updateStatus/{id}/{status}")
    public R updateStatus(@PathVariable String id ,@PathVariable Integer status){
        hospitalService.updateStatus(id,status);
        return R.ok();
    }

    

}
